package com.booter.ws.session;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;

/**
 * @author lcw
 * @date 2022/6/17 10:42
 * <p>
 * SessionConnectEvent 建立连接事件
 * SessionDisconnectEvent 断开连接事件
 * SessionSubscribeEvent : 订阅事件
 * SessionUnSubscribeEvent : 订阅事件
 */
@Component
@Slf4j
public class SessionDisconnectEventListener implements ApplicationListener<SessionDisconnectEvent> {
    @Override
    public void onApplicationEvent(SessionDisconnectEvent event) {
        StompHeaderAccessor wrap = StompHeaderAccessor.wrap(event.getMessage());
        log.info("【SessionConnectedEvent 监听事件类型:{}】，sessionId:{},command:{}", wrap.getCommand(), wrap.getSessionId(), wrap.getCommand());

    }
}
